<template>
	<view>
		<view class="toSearch">
			<view class="top-view">
				<u-icon name="search" color="#999999" size="28"></u-icon>
				<input placeholder-class="serce"  v-model="name" placeholder="搜索关键词" />
				<view class="" @tap="serch()" style="width: 20%;">搜索</view>
			</view>
		</view>
		<u-tabs :list="list" :is-scroll="true" :current="current" @change="change" active-color="#FF9101" bar-width="50" inactive-color="#333333"></u-tabs>
		<view class="detailList" v-for="(item,index) in detailList" :key="index" @tap="orderDetail(item)">
			<!--全部-->
			<view class="" v-if="item.delivery_status==-1">
				<view class="detailTop">
					<view class=""></view>
					<view class="">21212</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<view class="button_btn">
					<view class="deleteBtn" @tap="tapFukuans(item)">取消订单</view>
					<!-- <view class="button">去支付</view> -->
				</view>
			</view>
			<!--待支付-->
			<view class="" v-if="item.delivery_status==0">
				<view class="detailTop">
					<view class="">订单编号{{item.id}}</view>
					<view class="">待支付</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<view class="button_btn">
					<!-- <view class="deleteBtn">取消订单</view> -->
					<view class="button" >去支付</view>
				</view>
			</view>
			<!--待发货-->
			<view class="" v-if="item.delivery_status==1">
				<view class="detailTop">
					<view class="">订单编号{{item.id}}</view>
					<view class="">待发货</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<view class="button_btn">
					<view class="deleteBtn">查看详情</view>
					<!-- <view class="button" >去支付</view> -->
				</view>
			</view>
			<!--待收货-->
			<view class="" v-if="item.delivery_status==2">
				<view class="detailTop">
					<view class="">订单编号{{item.id}}</view>
					<view class="">待收货</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<view class="button_btn">
					<view class="button">确认收货</view>
				</view>
			</view>
			<!--拼团中-->
			<view class="" v-if="item.delivery_status==5">
				<view class="detailTop">
					<view class="">订单编号{{item.id}}</view>
					<view class="">拼团中</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<!-- <view class="button_btn">
					<view class="deleteBtn" @tap="tapFukuans(item)">取消订单</view>
				</view> -->
			</view>
			<!--已完成-->
			<view class="" v-if="item.delivery_status==3">
				<view class="detailTop">
					<view class="">订单编号{{item.id}}</view>
					<view class="">已完成</view>
				</view>
				<view class="circle_top">
					<view class="circle_top_img">
						<image :src="item.image"   mode="aspectFill"></image>
					</view>
					<view class="cirleMiddle">
						<view class="circle_top_texts">
							<view>{{item.goods_name}}</view>
						</view>
						<view class="circle_top_text">{{item.goods_spec}}*{{item.num}}</view>
						<view class="circle_top_text mount">￥ {{item.goods_money}}</view>
					</view>
				</view>
				<!-- <view class="button_btn">
					<view class="deleteBtn" @tap="tapFukuans(item)">取消订单</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '全部'
				}, {
					name: '待支付'
				}, {
					name: '待发货'
				}, {
					name: '待收货'
				},
				{
					name: '已完成'
				}],
				current: 0,
				detailList:[{
					course:'茶馆门店名称 >',
					num:'RGEE1565495262321',
					time:'2021-01-04 17:15',
					money:'+0.05'
				},{
					course:'茶馆门店名称 >',
					num:'RGEE1565495262321',
					time:'2021-01-04 17:15',
					money:'+0.05'
				},{
					course:'茶馆门店名称 >',
					num:'RGEE1565495262321',
					time:'2021-01-04 17:15',
					money:'+0.05'
				},{
					course:'茶馆门店名称 >',
					num:'RGEE1565495262321',
					time:'2021-01-04 17:15',
					money:'+0.05'
				}],
				type:-1,
				name:''
			}
		},
		onLoad(e) {
			if(e.type){
				this.current=e.type
				this.type = this.current-1
				console.log(this.type)
				// this.shops()
				// this.swiperCurrent=e.type
			}
			
		},
		onShow() {
			this.shops()
		},
		methods: {
			shops(){
				this.$myRequest({
					url: 'api/order/OrderList',
					method:'POST',
					data:{
						type:this.type,
						page:1,
						num:1000,
						name:this.name
					}
				}).then(res=>{
					console.log(res.data)
					if (res.data.code == 1) {
						this.detailList = res.data.data.list
					}
				})
			},
			serch(){
				this.$myRequest({
					url: 'api/order/OrderList',
					method:'POST',
					data:{
						type:this.type,
						page:1,
						num:1000,
						name:this.name
					}
				}).then(res=>{
					console.log(res.data)
					if (res.data.code == 1) {
						this.detailList = res.data.data.list
					}
				})
			},
			change(index) {
				this.current = index;
				this.type = this.current-1
				this.shops()
			},
			tapFukuans(item){
				console.log(item.id);
				this.$myRequest({
					url: 'api/order/clearOrder',
					method:'POST',
					data:{
						order_id:item.id
					}
				}).then(res=>{
					console.log(res.data)
					uni.showToast({
						icon:'none',
						title:res.data.msg
					})
					if (res.data.code == 1) {
							this.shops()
					}
				})
			},
			orderDetail(item){ //订单详情
				console.log(item.delivery_status);
					uni.navigateTo({
						url:'toPaid?type='+item.delivery_status+"&orderid="+item.id
					})
				// uni.navigateTo({
				// 	url:"orderGroup?type="+item.delivery_status+"&orderid="+item.id
				// })
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fafafa;
}
.detailList{
	width: 90%;
	padding:0 40rpx;
	margin:20rpx auto;
	// height: 229px;
	background: #FFFFFF;
	// display: flex;
	// justify-content: space-between;
	.detailTop{
		display: flex;
		justify-content: space-between;
		width: 100%;
		border-bottom: 1px solid #F2F2F2;
		font-size: 12px;
		height: 90rpx;
		line-height: 90rpx;
		color: #333333;
	}
	.detailBtm{
		font-size: 18px;
		font-weight: bold;
		line-height: 200rpx;
		color: #FF9101;
	}
}
.toSearch{
		height: 120rpx;
	}
	.top-view {
		width: 90%;
		margin: 20rpx auto;
		height: 40px;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 20px;
		display: flex;
		align-items: center;
		image {
			width: 36rpx;
			height: 36rpx;
			margin-left: 20rpx;
		}
		input {
			width: 100%;
			height: 40px;
			font-size: 14px;
			font-weight: 500;
			line-height: 40px;
			color: #807B7A;
			margin-left: 20px;
		}
		.serce{
			color: #807B7A;
		}
	}
	.cirleMiddle{
		width: 80%;
	}
	.circle_top {
		padding: 15px;
		border-top: 1px solid #F2F2F2;
		border-bottom: 1px solid #F2F2F2;
		display: flex;
		// justify-content: space-between;
		.circle_top_img image {
			width: 80px;
			height: 80px;
			border-radius: 8px;
		}
		.circle_top_img {
			width: 80px;
			height: 80px;;
			margin-right: 10%;
			border-radius: 8px;
		}
		.circle_top_texts{
			font-size: 14px;
			font-family: PingFang SC;
			font-weight: 500;
			line-height: 20px;
			color: #333333;
		}
		.circle_top_text {
			font-size: 10px;
			font-weight: 400;
			line-height: 14px;
			color: #666666;
			margin-top: 10px;
		}
		.mount {
			margin-top: 30px;
			font-size: 16px;
			font-weight: bold;
			line-height: 22px;
			color: #333333;
			text-align: right;
		}
	}
	.button_btn {
		margin: 5px;
		padding: 5px;
		display: flex;
		justify-content: flex-end;
		width: 100%;
		height: auto;
	}
	
	.button {
		text-align: center;
		color: #ffffff;
		font-size: 12px;
		// position: relative;
		// right: 30px;
		width: 70px;
		height: 28px;
		background: #FF9101;
		line-height: 28px;
		opacity: 1;
		border-radius: 12px;
	}
	.deleteBtn{
		text-align: center;
		color: #333;
		font-size: 12px;
		position: relative;
		right: 5px;
		width: 70px;
		height: 28px;
		background: #FFFFFF;
		border: 1px solid #333;
		border-radius: 90px;
		line-height: 28px;
		
	}
	
</style>
